a = eval(input())
b = eval(input())
mode = eval(input())
c = eval(input())
d = eval(input())
i = 2
gcd = 1
if mode == 1:
    f = (a * d) + (b * c)
    g = b * d
elif mode == 2:
    f = (a * d) - (b * c)
    g = b * d
elif mode == 3:
    f = a * c
    g = b * d
elif mode == 4:
    f = a * d
    g = b * c
if g !=0:
    if f == 0:
        print(f)
        print(1)
    if f != 0 and f % g  == 0:
        print(f // g)
        print(1)
    if f != 0 and f % g != 0:
        if f * g < 0:
            while i <= abs(f) and i <= abs(g):
                if abs(f) % i == 0 and abs(g) % i == 0:
                    gcd = i
                i += 1
            print(-abs(f//gcd))
            print(abs(g//gcd))
        if f * g > 0:
            while i <= f and i <= g:
                if f % i == 0 and g % i == 0:
                    gcd = i
                i += 1
            print(f//gcd)
            print(g//gcd)